package org.jiangy.authentication;

import io.jsonwebtoken.JwtException;
import io.jsonwebtoken.Jwts;

import javax.crypto.SecretKey;

/**
 * <p>创建时间: 2024/8/13 </p>
 *
 * @author <a href="mailto:jiangliu0316@outlook.com" rel="nofollow">蒋勇</a>
 */
public final class JJwtUtils {

    public static SecretKey key = Jwts.SIG.HS256.key().build();

    public static boolean trust(SecretKey key, String jws) {
        try {
            Jwts.parser().verifyWith(key).build().parseSignedClaims(jws);
            //OK, we can trust this JWT
            return true;

        } catch (JwtException e) {
            //don't trust the JWT!
            return false;
        }
    }
}
